package org.easy.tool.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.easy.tool.entity.Problem;
import org.easy.tool.entity.UserProblem;
import org.easy.tool.entity.UserProblemDetail;
import org.easy.tool.mapper.UserProblemDetailMapper;
import org.easy.tool.service.IUserProblemDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Valley
 * Created by Valley on 2023/8/30 15:16
 */
@Service
public class UserProblemDetailService extends ServiceImpl<UserProblemDetailMapper, UserProblemDetail> implements IUserProblemDetail {

    @Autowired
    UserProblemDetailMapper userProblemDetailMapper;

    /**
     * 功能：某个用户题目正确记录列表
     */
    @Override
    public List<UserProblemDetail> rightProblemList(String userId, String problemId) {
        LambdaQueryWrapper<UserProblemDetail> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserProblemDetail::getUserId, userId);
        wrapper.eq(UserProblemDetail::getProblemId, problemId);
        wrapper.eq(UserProblemDetail::getStatus, 1);
        return userProblemDetailMapper.selectList(wrapper);
    }

    /**
     * 功能：某个用户题目错误题目记录列表
     */
    @Override
    public List<UserProblemDetail> wrongProblemList(String userId, String problemId) {
        LambdaQueryWrapper<UserProblemDetail> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserProblemDetail::getUserId, userId);
        wrapper.eq(UserProblemDetail::getProblemId, problemId);
        wrapper.eq(UserProblemDetail::getStatus, 2);
        return userProblemDetailMapper.selectList(wrapper);
    }
}
